public class Solution1147 {
    public int longestDecomposition(String text) {
        if (text.equals("")){
            return 0;
        }
        for (int i=0,j=text.length()-1;i<j;i++,j--){
            if (text.substring(0,i+1).equals(text.substring(j))){
                return 2+longestDecomposition(text.substring(i+1,j));
            }
        }
        return 1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1147().longestDecomposition("ghiabcdefhelloadamhelloabcdefghi"));
    }
}
